package br.jcrsistemas.componentes;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class SysCampo extends JPanel{
	private final JLabel label = new JLabel("label");
	private final SysTextField field = new SysTextField();
	private final JLabel espacos = new JLabel("");
	private String textoLabel    = "";
	private int   iespacos       = 0;
	private boolean 	upperCase = true;
	private boolean     apenasNumero = false;
	private boolean 	obrigatorio = false;	
	
	public SysCampo() {
		super();
		setEspacos(iespacos);
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.fill = GridBagConstraints.VERTICAL;
		gbc_label.insets = new Insets(0, 0, 0, 5);
		gbc_label.anchor = GridBagConstraints.WEST;
		gbc_label.gridx = 0;
		gbc_label.gridy = 0;
		add(label, gbc_label);
		
		GridBagConstraints gbc_espacos = new GridBagConstraints();
		gbc_espacos.insets = new Insets(0, 0, 0, 5);
		gbc_espacos.gridx = 1;
		gbc_espacos.gridy = 0;
		add(espacos, gbc_espacos);
		
		GridBagConstraints gbc_field = new GridBagConstraints();
		gbc_field.fill = GridBagConstraints.BOTH;
		gbc_field.gridx = 2;
		gbc_field.gridy = 0;
		field.setObrigatorio(obrigatorio);
		field.setUpperCase(upperCase);
		field.setApenasNumero(apenasNumero);
		add(field, gbc_field);
	}
	public void setEspacos(int iespacos) {
		this.iespacos = iespacos;
		for(int i = 0;i < iespacos;i++) {
			espacos.setText(espacos.getText() + " ");
		}
	}
	public int getEspacos() {
		return iespacos;
	}
	public void setTextoLabel(String textoLabel) {
		this.textoLabel = textoLabel;
		label.setText(textoLabel);
	}
	public String getTextoLabel() {
		return textoLabel;
	}
	public void setUpperCase(boolean upperCase) {
		this.upperCase = upperCase;
		field.setUpperCase(upperCase);
	}
	public boolean isUpperCase() {
		return upperCase;
	}
	public void setApenasNumero(boolean apenasNumero) {
		this.apenasNumero = apenasNumero;
		field.setApenasNumero(apenasNumero);
	}
	public boolean isApenasNumero() {
		return field.isApenasNumero();
	}
	public void setObrigatorio(boolean obrigatorio) {
		this.obrigatorio = obrigatorio;
		field.setObrigatorio(obrigatorio);
	}
	public boolean isObrigatorio() {
		return obrigatorio;
	}
	

}
